package com.example.selfcontrol.controller;

import com.example.selfcontrol.config.Response;
import com.example.selfcontrol.dto.CommentDTO;
import com.example.selfcontrol.entity.Comment;
import com.example.selfcontrol.entity.resp.CommentResponse;
import com.example.selfcontrol.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/comments")
@Api(value = "评论视图")
public class CommentController {
    @Autowired
    private CommentService commentService ;

    @GetMapping("/{id}")
    @ApiOperation("获取当前id文章下的所以评论Info")
    public List<CommentDTO> getComments(@PathVariable Integer id) {
        return commentService .getComments(id) ;
    }


    @PostMapping("/sendComment")
    @ApiOperation("发送评论")
    public Response sendComment(@RequestBody Comment comment) { return commentService.sendComments(comment) ;}
}
